package mybatis;

import java.io.Reader;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class MyBatisManager {
	
	private static SqlSessionFactory sqlMapper;
	
	static String resources = 
		"mybatis/SqlMapConfig.xml";
	
	
	static {
		
		try {
			
			//leemos el archivo de configuracion
			Reader reader = 
				Resources.getResourceAsReader(resources);
			
			//instanciar el mapper
			sqlMapper = new SqlSessionFactoryBuilder()
				.build(reader);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static SqlSessionFactory 
					getSqlSessionFactory(){
		
		return sqlMapper;
		
	}
	

}
